//
//  ObserverLineTableViewCell.m
//  Rail
//
//  Created by hychen on 2018/3/2.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "ObserverLineTableViewCell.h"

@interface ObserverLineTableViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;

@end
@implementation ObserverLineTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self showArrowWithImage:nil];
    [self showBottomLineWithPaddingX:0 color:nil];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(PatrolLineModel *)model {
    _model = model;
    if ([model.snapshot_url1 objectIsNotEmpty]) {
        [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.snapshot_url1] placeholderImage:ImageNamed_bb(@"home_list_default_img")];
    }
    else if ([model.snapshot_url2 objectIsNotEmpty]) {
        [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.snapshot_url2] placeholderImage:ImageNamed_bb(@"home_list_default_img")];
    }
    else if ([model.snapshot_url3 objectIsNotEmpty]) {
        [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.snapshot_url3] placeholderImage:ImageNamed_bb(@"home_list_default_img")];
    }
    
    NSString *title = model.device_name;
    if (![title isKindOfClass:[NSString class]] || [title isEqualToString:@""]) {
        title = model.area_name;
    }
    self.titleLabel.text = title;
    self.timeLabel.text = [BMUtils chineseMMDDHHmmWithServiceTime:model.snapshot_time];
    
    NSInteger count = 0;
    if ([model.snapshot_url1 objectIsNotEmpty]) {
        count++;
    }
    if ([model.snapshot_url2 objectIsNotEmpty]) {
        count++;
    }
    if ([model.snapshot_url3 objectIsNotEmpty]) {
        count++;
    }
    self.countLabel.text = [NSString stringWithFormat:@"%ld张",count];
    
}
@end
